﻿/**
作者：常亮
时间：2009-11-17
功能：登录页代码
**/

function ShowMain() {

    ShowContent();
    document.getElementById("UserName").focus();
}
function GetUserAndPwd() {

    var username = document.getElementById("UserName").value;
    var userPwd = document.getElementById("PassWord").value;

    if (username == "") {
        MsgDlg('用户名不能为空！');
        return;
    }

    if (userPwd == "") {
        MsgDlg('密码不能为空！');
        return;
    }

    var url = encodeURI(SBasePath + '/action/Login.action');
    var pars = encodeURI("?UserAccount=" + username + "&UserPwd=" + userPwd);
    var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sGetProductAppli, onFailure: fGetProductAppli });

}

//成功
function sGetProductAppli(o) {
    var root = o.responseXML.documentElement;
    var Value = GetXmlData(root, "Value");

    if (Value == "True") {
        window.location.href = SBasePath + '/main.html';
    }
    else {
        var Msg = GetXmlData(root, "Msg");
        MsgDlg(Msg);
        document.getElementById("UserName").value="";
        document.getElementById("PassWord").value="";
        return false;
    }
}
//失败
function fGetProductAppli() {

}


function ShowContent() {

  var str = '';
      str+='<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">';
      str+='  <tr>';
      str+='      <td bgcolor="#e5f6cf"> &nbsp;</td>';
      str+='  </tr>';
      str+='  <tr>';
      str+='      <td height="608" background="images/login_03.gif">';
      str+='          <table width="862" border="0" align="center" cellpadding="0" cellspacing="0">';
      str+='               <tr>';
      str+='                  <td height="266" background="images/login_04.gif">&nbsp;</td>';
      str+='              </tr>';
      str+='              <tr>';
      str+='                  <td height="95px">';
      str+='                      <table width="100%" border="0" cellspacing="0" cellpadding="0">';
      str+='                          <tr>';
      str+='                              <td width="424" height="95" background="images/login_06.gif"> &nbsp;</td>';
      str+='                              <td width="183" background="images/login_07.gif">';
      str+='                                  <table width="100%" border="0" cellspacing="0" cellpadding="0">';
      str+='                                      <tr>';
      str+='                                          <td width="21%" height="30">';
      str+='                                              <div align="center">';
      str+='                                                  <span class="STYLE3">用户名</span></div>';
      str+='                                          </td>';
      str+='                                          <td width="79%" height="30">';
      str+= '                                              <input type="text" name="UserName" style="height: 18px; width: 130px; border: solid 1px #cadcb2;font-size: 12px; color: #81b432;">';
      str+='                                          </td>';
      str+='                                      </tr>';
      str+='                                      <tr>';
      str+='                                          <td height="30">';
      str+='                                              <div align="center">';
      str+='                                                  <span class="STYLE3">密  码</span>';
      str+='                                              </div>';
      str+='                                          </td>';
      str+='                                          <td height="30">';
      str += '                                              <input type="password" name="PassWord" style="height: 18px; width: 130px; border: solid 1px #cadcb2;font-size: 12px; color: #81b432;">';
      str+='                                          </td>';
      str+='                                      </tr>';
      str+='                                      <tr>';
      str+='                                          <td height="30"> &nbsp;</td>';
      str += '                                          <td height="30">&nbsp;';
      str += '<input onClick="GetUserAndPwd();" style=" vertical-align:middle;border:none;" type="image" src="images/dl.jpg">&nbsp;&nbsp;';
      str += '<input onClick="Clear()" style=" vertical-align:middle;border:none;" type="image" src="images/cz.jpg">';
      str+='                                          </td>';
      str+='                                      </tr>';
      str+='                                  </table>';
      str+='                               </td>';
      str+='                              <td width="255" background="images/login_08.gif">&nbsp;</td>';
      str+='                          </tr>';
      str+='                      </table>';
      str+='                  </td>';
      str+='              </tr>';
      str+='              <tr>';
      str+='                  <td height="247" valign="top" background="images/login_09.gif">';
      str+='                      <table width="100%" border="0" cellspacing="0" cellpadding="0">';
      str+='                          <tr>';
      str+='                              <td width="22%" height="30">&nbsp;</td>';
      str+='                              <td width="56%">&nbsp;</td>';
      str+='                             <td width="22%"> &nbsp;</td>';
      str+='                          </tr>';
      str+='                          <tr>';
      str+='                              <td>&nbsp;</td>';
      str+='                              <td height="30">';
      str+='                                  <table width="100%" border="0" cellspacing="0" cellpadding="0">';
      str += '                                      <tr>';
      str += '                                          <td width="44%" class="STYLE4 "height="20">&nbsp;</td>';
      str+='                                          <td width="56%" class="STYLE4"> 版本 2009V1.0 </td>';
      str+='                                      </tr>';
      str+='                                  </table>';
      str+='                              </td>';
      str+='                              <td>&nbsp;</td>';
      str+='                          </tr>';
      str+='                      </table>';
      str+='                  </td>';
      str+='              </tr>';
      str+='          </table>';
      str+='      </td>';
      str+='  </tr>';
      str+='  <tr>';
      str+='      <td bgcolor="#a2d962">&nbsp;</td>';
      str+='  </tr>';
      str+='</table>';
      str+='<map name="Map">';
      str+='  <area shape="rect" coords="3,3,36,19" href="#" >';
      str+='  <area shape="rect" coords="40,3,78,18" href="#">';
      str += '</map>';
      
      $("Login").innerHTML = str;
  }

  function Clear() {
      document.getElementById("UserName").value = "";
      document.getElementById("PassWord").value = "";
      
  }